/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.hiddendanger.controller;

import com.koron.common.StaffAttribute;
import com.koron.common.bean.StaffBean;
import com.koron.common.permission.SPIAccountAnno;
import com.koron.hazardsource.domain.HiddenDanger;
import com.koron.hiddendanger.service.api.TempHiddenDangerService;
import com.koron.hiddendanger.uitls.BusinessCode;
import com.koron.system.annotation.Log;
import com.koron.system.discrete.BusinessManipulation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.swan.bean.MessageBean;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Api(tags = "tempHiddenDanger",description = "临时隐患入库接口")
@RestController
@RequestMapping("/tempHiddenDanger")
public class TempHiddenDangerController {
	@Autowired
	private TempHiddenDangerService service;

	@ApiOperation("临时隐患入库")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "title", value = "标题", paramType = "query", dataType = "String"),
        @ApiImplicitParam(name = "note", value = "说明", paramType = "query", dataType = "String")
    })
    @RequestMapping(value = "/merge.htm", method = { RequestMethod.POST })
    @Log(title = "临时隐患入库", businessModule = "临时隐患", businessManipulation = BusinessManipulation.INSERT)
	public MessageBean<?> merge(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, @RequestBody List<HiddenDanger> hdList,String title, String note){
		if (null==user){
			MessageBean<?> msg=new MessageBean<>();
			msg.setCode(BusinessCode.NOT_LONGIN.getCode());
			msg.setDescription(BusinessCode.NOT_LONGIN.getDescription());
			return msg;
		}
		return service.merge(user, hdList, title, note);
	}
}
